// student.ts
import request from '@/utils/request'

// 分页查询
export const getStudent = (params: any) =>
  request({
    'url': `/student/page`,
    'method': 'get',
    params
  })

// 新增学生
export const addStudent = (params: any) =>
  request({
    'url': '/student',
    'method': 'post',
    data:params
  })

// 根据id查询学生
export const findStudentById = (id: number) =>
  request({
    'url': `/student/${id}`,
    'method': 'get',
  })

  export function getStudentCount(params) {
    return request({
      url: '/student/count',
      method: 'get',
      params
    })
  }

// 根据id查询学生
export const findStudentBySno = (sno: string) =>
  request({
    'url': `/student`,
    'method': 'get',
    params: { sno }
  })

// 更新学生
export const updateStudent = (params: any) =>
  request({
    'url': '/student',
    'method': 'put',
    data:params
  })

// 批量删除学生
// 批量删除学生 - 修改为使用逗号分隔的ID字符串
export const deleteBatchStudents = (ids: number[]) =>
  request({
    'url': `/student`,
    'method': 'delete',
    params: { 
      ids: ids.join(',') // 将数组转换为逗号分隔的字符串
    }
  })